package com.xps.and.yuntong.Ui;

import android.os.Bundle;

import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MyLocationConfiguration;
import com.xps.and.yuntong.App;
import com.xps.and.yuntong.R;
import com.xps.and.yuntong.base.BaseActivity;

/**
 * Created by administrator on 2017-12-15.
 */

public class ZhuyeChakanActivity extends BaseActivity {


    private MapView mapView;
    private BaiduMap baiduMap;
    private LocationClient mLocationClient;

    @Override
    protected int getLayout() {
        return R.layout.activity_chakan_dingdan;
    }

    @Override
    protected void setData() {

    }

    @Override
    protected void init(Bundle inBundle) {
        mapView = (MapView) findViewById(R.id.mapView);
        setUpMap();
    }

    void setUpMap() {
        mapView.showZoomControls(false);
        mapView.showScaleControl(false);
        baiduMap = mapView.getMap();
        baiduMap.getUiSettings().setCompassEnabled(false);
        baiduMap.getUiSettings().setZoomGesturesEnabled(true);
        baiduMap.getUiSettings().setOverlookingGesturesEnabled(false);
        baiduMap.setMyLocationEnabled(true);
        baiduMap.setViewPadding(35, 0, 20, 50);
        baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.FOLLOWING, true, null));

        mLocationClient = new LocationClient(App.getInstance());
        //activity里是否不能监听定位
//        mLocationClient.registerLocationListener(this);
        periodLocation();
    }


    //周期性定位的配置
    public void periodLocation() {
        LocationClientOption option = new LocationClientOption();
        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
        option.setCoorType("bd09ll");
        int span = 1000 * 5;
        option.setScanSpan(span);
        option.setIsNeedAddress(true);
        option.setOpenGps(true);
        option.setLocationNotify(false);
        option.setIsNeedLocationDescribe(true);
        option.setIsNeedLocationPoiList(true);
        option.setIgnoreKillProcess(false);
        option.SetIgnoreCacheException(false);
        option.setEnableSimulateGps(false);
        mLocationClient.setLocOption(option);
        mLocationClient.start();
    }




    @Override
    public void onPause() {
        super.onPause();
        mapView.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        mapView.onResume();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mapView.onDestroy();
        mapView = null;

    }
}
